package cn.yy.common.exception;

import cn.yy.common.web.Message;
import cn.yy.common.web.MessageUtil;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 映射 /error 的返回内容
 */
@RestController
public class NotFoundException implements ErrorController {

    @RequestMapping({"/error"})
    public Message error(HttpServletRequest request){
        return MessageUtil.error("您访问的资源地址不存在！");
    }

    @Override
    public String getErrorPath() {
        return "/error";
    }
}
